﻿namespace PLCSharp.CoreModel.Common
{
    /// <summary>
    /// 流程模型
    /// </summary>
    public class FlowModel
    {


        private int _Step;
        /// <summary>
        /// 流程步 
        /// </summary>
        public int Step
        {
            get { return _Step; }
            set
            {
                _Step = value;

                StepTime = DateTime.Now;
            }
        }


        /// <summary>
        /// 时间
        /// </summary>
        public DateTime StepTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 时间
        /// </summary>
        public DateTime FlowStarTime { get; set; } = DateTime.Now;
        public bool Done { get; set; }
        public FlowModel()
        {

            Reset();
        }

        public void Reset()
        {
            Done = false;
            Step = 0;
            StepTime = DateTime.Now;
            FlowStarTime = DateTime.Now;
        }
        /// <summary>
        /// 步超时
        /// </summary>
        /// <param name="second"></param>
        /// <returns></returns>
        public bool CheckStepTime(double second)
        {
            return StepTime.AddSeconds(second) < DateTime.Now;
        }

        /// <summary>
        /// 流程超时
        /// </summary>
        /// <param name="second"></param>
        /// <returns></returns>
        public bool CheckFlowTime(double second)
        {
            return StepTime.AddSeconds(second) < DateTime.Now;
        }

    }
}
